<template>
  <div class="main-content">
    <div>
      <el-row :gutter="10">
        <el-col :span="4" style="margin: 15px;" v-for="item in topNews" :key="item.id">
          <div class="card" style="cursor: pointer;" @click="detailInfo(item.id)">
            <img :src="item.img" alt="" style="width: 100%; height: 150px">
            <div style="margin: 5px 0">{{ item.infoTitle }}</div>
            <div style="text-align: right">
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
    <div style="margin: 10px 0" v-if="total">
      <el-pagination background @current-change="handleCurrentChange" @size-change="handleSizeChange"
        :current-page="page" :page-size="pageSize" layout="total, prev, pager, next" :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
  name: "FrontServe",
  data() {
    return {
      serveList: [],
      user: JSON.parse(localStorage.getItem('xm-user') || '{}'),
      infoForm: { page: 1, pageSize: 10 }
    }
  },
  created() {
    this.getInfoActions(this.infoForm)
  },
  computed: {
    ...mapState('userInfo', ['topNews','total']),
  },
    methods: {
      ...mapActions('userInfo', ['getInfoActions']),
      detailInfo(id) {
        this.$router.push('/front/infoDetail?id=' + id)
      },

      handleCurrentChange(page) {
        this.infoForm.page = page
        this.getInfoActions(this.infoForm)
      },
      handleSizeChange(pageSize) {
        this.infoForm.pageSize = pageSize
        this.getInfoActions(this.infoForm)
      },
  }
}
</script>

<style scoped>

</style>